package com.mdd.common.enums;

import com.google.common.collect.Maps;

import java.util.Map;

public enum OrderStatusEnum {
    //订单状态;0-待支付;1-预约中;2-服务中;3-已完成;4-已关闭
    WAIT_PAY(0, "待支付"),
    RESERVE(1, "预约中"),
    SERVICING(2, "服务中"),
    FINISHED(3, "已完成"),
    CLOSE(4, "已关闭"),
    DISPATCHING(5, "派单中");

    private final int status;
    private final String desc;

    OrderStatusEnum(int status, String desc) {
        this.status = status;
        this.desc = desc;
    }

    /**
     * 获取状态码
     *
     * @return Long
     * @author fzr
     */
    public int getStatus() {
        return this.status;
    }

    /**
     * 获取提示
     *
     * @return String
     * @author fzr
     */
    public String getDesc() {
        return this.desc;
    }

    public static Map<Integer, String> getMap() {
        Map<Integer, String> map = Maps.newHashMap();
        for (OrderStatusEnum codeEnum : OrderStatusEnum.values()) {
            map.put(codeEnum.status, codeEnum.desc);
        }
        return map;
    }

    public static String getDesc(int status) {
        for (OrderStatusEnum codeEnum : OrderStatusEnum.values()) {
            if (codeEnum.status == status) {
                return codeEnum.desc;
            }
        }
        return null;
    }
}
